home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-05 | 1.4 KB | 55 lines | [MATS/MATL] |
- echo off;
- % NUMERICAL METHODS: MATLAB Programs, (c) John H. Mathews 1994
- % To accompany the text:
- % NUMERICAL METHODS for Mathematics, Science and Engineering, 2nd Ed, 1992
- % Prentice Hall, Englewood Cliffs, New Jersey, 07632, U.S.A.
- % This free software is complements of the author.
-
- % Algorithm 11.QR (Householder Reduction to Tridiagonal Form).
- % (Followed by the QR Method with Shifts).
- % Section 11.4, Eigenvalues of Symmetric Matrices, Page 574
- echo on; clc; format long; hold off; clear
-
- clc;
-
- % HOUSEHOLDER`S METHOD followed by the QR METHOD
-
- % Remark. house2.m and qr2.m are used for Algorithm 11.QR
-
- % First proceed with Householder`s method.
-
- A = [4 2 2 1;
- 2 -3 1 5;
- 2 1 3 1;
- 1 5 1 2];
-
- B = house2(A,1);
-
- pause % Press any key to continue.
-
- clc;
- Ms1 = 'The matrix A is:';
- Ms2 = 'The similar tridiagonal matrix B is:';
- clc,disp(' '),disp(Ms1),disp(A),disp(Ms2),disp(B)
-
- pause % Press any key to continue.
-
- clc;
-
- epsilon = 5e-15;
-
- D = qr2(B,epsilon,1);
-
- pause % Press any key to continue.
-
- clc;
- Mx1 = 'Implementation of Householder reduction,';
- Mx2 = 'followed by the QR method with shifts.';
- Mx3 = 'The matrix A is:';
- Mx4 = 'The similar diagonal matrix is:'
- Mx5 = 'The eigenvalues are:';
- clc,echo off,diary output,...
- disp(' '),disp(Mx1),disp(Mx2),...
- disp(' '),disp(Mx3),disp(A),disp(Mx4),...
- disp(diag(D)),disp(Mx5),disp(D),diary off,echo on
-